package com.kuang.pojo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

public class People {
    //    这是注解,它要求属性名和xml里的名称尽量一样,如果属性名和beans中的值名字不同,就会按照相同类型自动装配,如果类型相同的有多个,就需要@Qualifier(value="nikanwo")来指定默认的属性名
    @Autowired
    @Qualifier(value="nikanwo")
    private Cat cat;
    @Autowired
    private Dog dog;
    private String name;

    public Cat getCat() {
        return cat;
    }
    //有了@Autowired注解,就不需要设置set方法了
    public void setCat(Cat cat) {
        this.cat = cat;
    }

    public Dog getDog() {
        return dog;
    }

    public void setDog(Dog dog) {
        this.dog = dog;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "people{" +
                "cat=" + cat +
                ", dog=" + dog +
                ", name='" + name + '\'' +
                '}';
    }
}
